package ua.com.musicdownloader.controller;

import ua.com.musicdownloader.model.DAO;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created with IntelliJ IDEA.
 * User: Ostap
 * Date: 20.05.12
 * Time: 17:45
 * To change this template use File | Settings | File Templates.
 */
public class LoginController extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String username = request.getParameter("username");
        String pass = request.getParameter("password");
        if(new DAO().checkLogin(username,pass)){
            request.setAttribute("username",username);
            request.getRequestDispatcher("WEB-INF/good.jsp").forward(request,response);
        } else {
            request.getRequestDispatcher("WEB-INF/bad.jsp").forward(request,response);
        }
    }
}
